package cn.com.cym.gamezao.config;

import cn.com.cym.gamezao.annotation.CommonApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * 配置Knife4j
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    @Bean(value = "defaultDocket")
    public Docket defaultDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("公用Api")
                        .description("后端API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("公用api")
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(CommonApi.class))
                .paths(PathSelectors.any())
                .build();
        return docket;
        //RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web")
    }

    @Bean(value = "authorizeDocket")
    public Docket authorizeDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("权限相关API")
                        .description("权限相关API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("权限")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.authorize"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    @Bean(value = "demoDocket")
    public Docket demoDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("demo相关API")
                        .description("demo相关API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("demo")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.demo"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    @Bean(value = "gameDocket")
    public Docket gameDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("游戏相关API")
                        .description("游戏相关API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("游戏")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.game"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    @Bean(value = "weeklyDocket")
    public Docket weeklyDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("周报相关API")
                        .description("周报相关API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("周报")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.weekly"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean(value = "singleDocket")
    public Docket singleDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("单页面接口相关API")
                        .description("单页面接口相关API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("单页面接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.single"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean(value = "recruitDocket")
    public Docket recruitDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("医院招聘API")
                        .description("医院招聘API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("医院招聘")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.recruit"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean(value = "xmuDocket")
    public Docket xmuDocket() {
        // 联系人信息
        Contact contact = new Contact("gameZao", "https://quicklydoit.cn", "cym1358723682@163.com");
        // 创建 Docket
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("医院招聘API")
                        .description("医院招聘API")
                        .termsOfServiceUrl("https://quicklydoit.cn")
                        .contact(contact)
                        .version("1.0")
                        .build())
                .groupName("学校相关")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.com.cym.gamezao.web.xmu"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

}
